#include "mxsetup.h"

               PRESERVE8      ; fix the L6306W waring
               AREA |.text|, CODE, READONLY
/* the system entry point */
__start         PROC
               EXPORT __start
               IMPORT __stack_base
               IMPORT mxboot
               IMPORT vector_set
               IMPORT clean_bss_section
               /* set the SP, although the hardware will automatically set SP after reset,
                  but it is necessary to manually set it when using the bootloader to startup the kernel */
               ldr r0, =__stack_base
               mov sp, r0
               /* set the vector for BootLoader,
                  if the kernel is not loaded by Bootloadr, it doesn't matter whether vector is set or not because of auto map of CM4 */
               ldr r0, =vector_set
               blx r0
               /* clear the .bss section */
               ldr r0, =clean_bss_section
               blx r0
#ifdef MXSETUP_LOADREGION_IS_FLASH
               IMPORT copy_data_section
               /* copy the .data's data from FLASH to RAM, need use `--datacompressor off` option
                  in armlink that turn off auto COMPRESSED function */
               ldr r0, =copy_data_section
               blx r0
#endif
               /* boot system */
               ldr r0, =mxboot
               blx r0
               b .
               nop            ; fix the A1581W waring
               ENDP

               END
